package com.melody.common.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * @Author: zengxz
 * @Description: TODO
 * @DateTime: 2025-05-29 17:24
 **/
// java example
@Slf4j
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

//    @Override
//    public void insertFill(MetaObject metaObject) {
//        this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
//    }
//
//    @Override
//    public void updateFill(MetaObject metaObject) {
//        this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
//    }
@Override
public void insertFill(MetaObject metaObject) {
    log.info("开始插入填充...");
    this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());
}

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("开始更新填充...");
        this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
    }
}